<%--
  Created by IntelliJ IDEA.
  User: 王俊波
  Date: 2022/3/29
  Time: 9:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--分页条的开始--%>
<div id="page_nav">
    <c:if test="${requestScope.page.pageNo>1}">
        <a href="${requestScope.page.url}&pageNo=1">首页</a>
        <a href="${requestScope.page.url}&pageNo=${requestScope.page.pageNo-1}">上一页</a>
    </c:if>
    <%--总页码小于等于5--%>
    <c:choose>
        <c:when test="${requestScope.page.pageTotal<=5}">
            <c:forEach begin="1" end="${requestScope.page.pageTotal}"  var="i" >
                <c:if test="${i==requestScope.page.pageNo}">
                    ${i}
                </c:if>
                <c:if test="${i!=requestScope.page.pageNo}">
                    <a href="${requestScope.page.url}&pageNo=${i}">【${i}】</a>
                </c:if>
            </c:forEach>
        </c:when>
        <%--情况二 总页码大于5 假定页码数为10--%>
        <c:when test="${requestScope.page.pageTotal>5}">
            <c:choose >
                <%--小情况一 当前的页码数为前三个页码,页面的均码为1，2，3，4，5--%>
                <c:when test="${requestScope.page.pageNo<=3}">
                    <c:forEach begin="1" end="5"  var="i" >
                        <c:if test="${i==requestScope.page.pageNo}">
                            ${i}
                        </c:if>
                        <c:if test="${i!=requestScope.page.pageNo}">
                            <a href="${requestScope.page.url}&pageNo=${i}">【${i}】</a>
                        </c:if>
                    </c:forEach>
                </c:when>

                <%--小情况2 当前的页码数为后三个页码,页面的均码为6，7，8，9，10--%>
                <c:when test="${requestScope.page.pageNo>requestScope.page.pageTotal-3}">
                    <c:forEach begin="${requestScope.page.pageTotal-4}" end="${requestScope.page.pageTotal}"  var="i" >
                        <c:if test="${i==requestScope.page.pageNo}">
                            ${i}
                        </c:if>
                        <c:if test="${i!=requestScope.page.pageNo}">
                            <a href="${requestScope.page.url}&pageNo=${i}">【${i}】</a>
                        </c:if>
                    </c:forEach>
                </c:when>

                <%--小情况3 当前的页码数为其他的页码--%>
                <c:otherwise>
                    <c:forEach begin="${requestScope.page.pageNo-2}" end="${requestScope.page.pageNo+2}"  var="i" >
                        <c:if test="${i==requestScope.page.pageNo}">
                            ${i}
                        </c:if>
                        <c:if test="${i!=requestScope.page.pageNo}">
                            <a href="${requestScope.page.url}&pageNo=${i}">【${i}】</a>
                        </c:if>
                    </c:forEach>
                </c:otherwise>
            </c:choose>
        </c:when>
    </c:choose>

    <c:if test="${requestScope.page.pageNo<requestScope.page.pageTotal}"></c:if>
    <a href="${requestScope.page.url}&pageNo=${requestScope.page.pageNo+1}">下一页</a>
    <a href="${requestScope.page.url}&pageNo=${requestScope.page.pageTotal}">末页</a>
    共${requestScope.page.pageTotal}页，${requestScope.page.pageTotalCount}条记录 到第<input value="${requestScope.page.pageNo}" name="pn" id="pn_input"/>页
    <input id="searchPageBtn" type="button" value="确定">



</div>
<%--分页条的结束--%>